package com.js.admin.mapper;

import com.js.admin.entity.BaseGroup;
import com.js.common.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;

/**
 * @author： ygl
 * @date： 2018/11/01-17:03
 * @Description：
*/
public interface BaseGroupMapper extends BaseMapper<BaseGroup> {

    /**
     *
     * @param groupId
     */
    @Delete("delete from base_group_member where group_id = #{groupId}")
    void deleteGroupMembersById (@Param("groupId") String groupId);

    /**
     *
     * @param groupId
     */
    @Delete("delete from base_group_leader where group_id = #{groupId}")
    void deleteGroupLeadersById (@Param("groupId") String groupId);

    /**
     *
     * @param id
     * @param groupId
     * @param userId
     * @param tenantId
     */
    @Insert("insert into base_group_member (id,group_id,user_id,tenant_id) " +
            "values( #{id},#{groupId},#{userId},#{tenantId} )")
    void insertGroupMembersById (@Param("id") String id,@Param("groupId") String groupId,@Param("userId") String userId,@Param("tenantId") String tenantId);

    /**
     *
     * @param id
     * @param groupId
     * @param userId
     * @param tenantId
     */
    @Insert(" insert into base_group_leader (id,group_id,user_id,tenant_id) " +
            "values(#{id},#{groupId},#{userId},#{tenantId})" )
    void insertGroupLeadersById (@Param("id") String id,@Param("groupId") String groupId,@Param("userId") String userId,@Param("tenantId") String tenantId);
}